<?php

namespace Database\Factories;

use App\Models\Tag;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Tag>
 */
class TagFactory extends Factory
{
    protected $model = Tag::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        // 中文标签列表（TagSeeder 中已定义，这里作为备用）
        $tags = [
            'PHP', 'Laravel', 'Vue.js', 'React', 'JavaScript',
            '前端开发', '后端开发', '全栈开发', '移动开发',
            '数据库', 'MySQL', 'Redis', 'MongoDB',
            'UI设计', 'UX设计', '交互设计',
            '产品策略', '产品设计', '产品运营',
            '团队管理', '项目管理', '敏捷开发',
        ];
        
        $name = $this->faker->randomElement($tags);
        
        return [
            'name' => $name,
            'slug' => Str::slug($name),
            'description' => "关于 {$name} 的相关内容和资源",
            'is_visible' => true,
            'meta_title' => $name,
            'meta_description' => "探索 {$name} 相关的内容和资源",
        ];
    }

    public function hidden(): static
    {
        return $this->state(function (array $attributes) {
            return [
                'is_visible' => false,
            ];
        });
    }

    public function withMeta(string $title, string $description): static
    {
        return $this->state(function (array $attributes) use ($title, $description) {
            return [
                'meta_title' => $title,
                'meta_description' => $description,
            ];
        });
    }
} 